package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TArea;
import com.ruoyi.system.service.ITAreaService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 车位区域Controller
 * 
 * @author ruoyi
 * @date 2022-11-29
 */
@RestController
@RequestMapping("/system/area")
public class TAreaController extends BaseController
{
    @Autowired
    private ITAreaService tAreaService;

    @GetMapping("/getListAreaId")
    public TableDataInfo selectAreaByaredId(@RequestBody TArea tArea){
        List<TArea> tAreas = tAreaService.selectAredByareaId(tArea);
        return getDataTable(tAreas);
    }
    
    /**
     * 查询车位区域列表
     */
    @PreAuthorize("@ss.hasPermi('system:area:list')")
    @GetMapping("/list")
    public TableDataInfo list(TArea tArea)
    {
        startPage();
        List<TArea> list = tAreaService.selectTAreaList(tArea);
        return getDataTable(list);
    }

    /**
     * 导出车位区域列表
     */
    @PreAuthorize("@ss.hasPermi('system:area:export')")
    @Log(title = "车位区域", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TArea tArea)
    {
        List<TArea> list = tAreaService.selectTAreaList(tArea);
        ExcelUtil<TArea> util = new ExcelUtil<TArea>(TArea.class);
        util.exportExcel(response, list, "车位区域数据");
    }

    /**
     * 获取车位区域详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:area:query')")
    @GetMapping(value = "/{areaid}")
    public AjaxResult getInfo(@PathVariable("areaid") Long aid)
    {
        return success(tAreaService.selectTAreaByAreaid(aid));
    }

    /**
     * 新增车位区域
     */
    @PreAuthorize("@ss.hasPermi('system:area:add')")
    @Log(title = "车位区域", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TArea tArea)
    {
        return toAjax(tAreaService.insertTArea(tArea));
    }

    /**
     * 修改车位区域
     */
    @PreAuthorize("@ss.hasPermi('system:area:edit')")
    @Log(title = "车位区域", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TArea tArea)
    {
        return toAjax(tAreaService.updateTArea(tArea));
    }

    /**
     * 删除车位区域
     */
    @PreAuthorize("@ss.hasPermi('system:area:remove')")
    @Log(title = "车位区域", businessType = BusinessType.DELETE)
	@DeleteMapping("/{areaids}")
    public AjaxResult remove(@PathVariable Long[] areaids)
    {
        return toAjax(tAreaService.deleteTAreaByAreaids(areaids));
    }
}
